'use strict';

// 获取菜单
function treeMenu() {
	var nav_count=0;
    var h1=0;
    var h2=0;
    var h3=0;
    var h4=0;
    var nav = [];
    // 生产
    $('#md').find('h1,h2,h3,h4').each(function(i, el) {
        var txt=$(this).text();
        var thisid = i ;
        var e = $(el);
        if (e.attr('id') != undefined) {
            thisid = e.attr('id');
        };
        var lv = 1;
        switch(e.get(0).tagName){
            case "H1":
                lv = 1;
                break;
            case "H2":
                lv = 2;
                break;
            case "H3":
                lv = 3;
                break;
            case "H4":
                lv = 4;
                break;
            default:
                lv = 1;
                break;
        }
        nav.push({id:thisid ,lv:lv ,title:txt });
    });

	return nav;
}